package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsOrderGoodsMapper;
import com.qf.mapper.DtsOrderMapper;
import com.qf.mapper.DtsUserMapper;
import com.qf.pojo.DtsOrder;
import com.qf.pojo.DtsOrderGoods;
import com.qf.pojo.DtsUser;
import com.qf.service.DtsOrderGoodsService;
import com.qf.service.DtsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/10/19 21:48
 */
@Service
public class DtsOrderGoodsServiceImpl implements DtsOrderGoodsService {

    @Autowired
    DtsUserMapper userMapper;
    @Autowired
    DtsOrderMapper orderMapper;
    @Autowired
    DtsOrderGoodsMapper orderGoodsMapper;

    @Override
    public Map<String,Object> selectdetail(Integer id) {

        LambdaQueryWrapper<DtsOrder> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsOrder::getId,id);
        DtsOrder order = orderMapper.selectOne(wrapper);

        LambdaQueryWrapper<DtsOrderGoods> wrapper1 = new LambdaQueryWrapper<>();
        wrapper1.eq(DtsOrderGoods::getOrderId,id);
        List<DtsOrderGoods> orderGoods = orderGoodsMapper.selectList(wrapper1);

        LambdaQueryWrapper<DtsUser> wrapper2 = new LambdaQueryWrapper<>();
        wrapper2.eq(DtsUser::getId,order.getUserId());
        DtsUser user = userMapper.selectOne(wrapper2);

        Map<String,Object> data = new HashMap<>();
        data.put("orderGoods",orderGoods);
        data.put("user",user);
        data.put("order",order);
        return data;
    }
}
